package com.itasura.factorykit;

import lombok.extern.slf4j.Slf4j;

import static com.itasura.factorykit.WeaponType.*;

/**
 * @author sailor wang
 * @date 2018/11/21 4:28 PM
 * @description
 */
@Slf4j
public class App {

    public static void main(String[] args) {
        WeaponFactory factory = WeaponFactory.factory(builder -> {
            builder.add(AXE,Axe::new);
            builder.add(BOW,Bow::new);
            builder.add(SPEAR,Spear::new);
            builder.add(SWORD,Sword::new);
        });
        Weapon axe = factory.create(AXE);
        axe.fight();

        Weapon sword = factory.create(SWORD);
        sword.fight();

        Weapon spear = factory.create(SPEAR);
        spear.fight();

        Weapon bow = factory.create(BOW);
        bow.fight();
    }
}